package cn.tsmchina.one.dao.user;

import java.util.List;

import org.springframework.stereotype.Repository;

import cn.tsmchina.one.dao.BaseDaoSupport;
import cn.tsmchina.one.domain.user.User;
import cn.tsmchina.one.util.C;

/**
 * Description:
 * @author zhaoying 
 * @date 2013-10-4
 * @version 1.0
 * Copyright: Copyright (c) 2013 TSM,Inc
 */
@Repository
public class UserManageDaoImpl extends BaseDaoSupport<User> implements UserManageDao {

	@Override
	public List<User> getUsers(int page, long customerId) {
		String hql = "from User u  where u.customerId=? order by u.createDate desc";
		return lists(hql,page,C.Paging.SIZE, new Object[]{customerId});
	}

	@Override
	public int getTotal(long customerId) {
		String hql = "select count(*) from User u where u.delflag = 0 and u.customerId=?";
		return count(hql, customerId);
	}

	@Override
	public User getUserById(Long userId) {
		return super.findById(userId);
	}

	@Override
	public void updateUser(User user) {
		super.update(user);
	}

}

